package com.gc.controller.teachclassServlet;



import com.gc.service.TeachClassService;
import com.gc.service.impl.TeachClassServiceImpl;
import com.gc.util.result.R;
import com.gc.vo.TeachClassShow;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "teachclassFind", value = "/teachclassFind" )
public class teachclassFind extends HttpServlet {
    TeachClassService ts = new TeachClassServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Gson gson = new Gson();
        List<TeachClassShow> teachclasss = ts.FindAll();
        response.getWriter().write(gson.toJson(R.ok().data(teachclasss)));
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Gson gson = new Gson();
        List<TeachClassShow> teachclasss = ts.FindAll();
        System.out.println("拿到了数据");
        response.getWriter().write(gson.toJson(R.ok().data(teachclasss)));
    }
}
